package cn.limc.ohoscharts.demo.slice;

import cn.limc.ohoscharts.demo.common.BaseAbility;
import cn.limc.ohoscharts.demo.ResourceTable;
import cn.limc.ohoscharts.axis.Axis;
import cn.limc.ohoscharts.entity.IStickEntity;
import cn.limc.ohoscharts.entity.ListChartData;
import cn.limc.ohoscharts.event.IZoomable;
import cn.limc.ohoscharts.view.MACDChart;
import ohos.aafwk.content.Intent;
import ohos.agp.utils.Color;

public class MACDChartAbility extends BaseAbility {

  MACDChart macdChart;

  @Override
  public void onStart(Intent intent) {
    super.onStart(intent);
    super.setUIContent(ResourceTable.Layout_ability_macdchart);
    initMACDChart();
  }

  private void initMACDChart() {

    macdChart = (MACDChart) findComponentById(ResourceTable.Id_macdchart);
    macdChart.setMaxValue(300000);
    macdChart.setMinValue(-300000);
    // macdChart.setDisplayCrossXOnTouch(true);
    // macdChart.setDisplayCrossYOnTouch(true);
    macdChart.setLatitudeNum(4);
    macdChart.setLongitudeNum(3);
    macdChart.setDisplayFrom(0);
    macdChart.setDisplayNumber(10);
    macdChart.setMinDisplayNumber(5);
    macdChart.setZoomBaseLine(IZoomable.ZOOM_BASE_LINE_CENTER);
    macdChart.setAxisXColor(Color.LTGRAY.getValue());
    macdChart.setAxisYColor(Color.LTGRAY.getValue());
    macdChart.setLatitudeColor(Color.GRAY.getValue());
    macdChart.setLongitudeColor(Color.GRAY.getValue());
    macdChart.setBorderColor(Color.LTGRAY.getValue());
    macdChart.setLongitudeFontColor(Color.WHITE.getValue());
    macdChart.setLatitudeFontColor(Color.WHITE.getValue());
    macdChart.setMacdDisplayType(MACDChart.MACD_DISPLAY_TYPE_STICK);
    macdChart.setPositiveStickColor(Color.RED.getValue());
    macdChart.setNegativeStickColor(Color.CYAN.getValue());
    macdChart.setMacdLineColor(Color.CYAN.getValue());
    macdChart.setDeaLineColor(Color.YELLOW.getValue());
    macdChart.setDiffLineColor(Color.WHITE.getValue());
    macdChart.setDataQuadrantPaddingTop(5);
    macdChart.setDataQuadrantPaddingBottom(5);
    macdChart.setDataQuadrantPaddingLeft(5);
    macdChart.setDataQuadrantPaddingRight(5);
    // macdChart.setAxisYTitleQuadrantWidth(50);
    // macdChart.setAxisXTitleQuadrantHeight(20);
    macdChart.setAxisXPosition(Axis.AXIS_X_POSITION_BOTTOM);
    macdChart.setAxisYPosition(Axis.AXIS_Y_POSITION_RIGHT);

    // 设置stickData
    macdChart.setStickData(new ListChartData<IStickEntity>(macd));
  }
}
